package cn.edu.live.controller;

import cn.edu.live.status.RespStatus;

import com.alibaba.fastjson.JSONObject;
import com.jfinal.core.Controller;

/**
 * 直播时提供功能的controller
 * 
 * @author zhagz
 * 
 */
public class LiveController extends Controller {

	/**
	 * 发问题
	 */
	public void sendQuestion() {
		int code = RespStatus.UNKNOWN_ERROR;
		String msg = "请先登录！";

		String username = getSessionAttr("username");

		if (username == null) {
			renderJson(respJson(code, msg));
			return;
		}

	}

	/**
	 * 拼接返回json对象用
	 * 
	 * @param code
	 * @param msg
	 * @return
	 */
	private JSONObject respJson(int code, String msg) {
		JSONObject js = new JSONObject();
		js.put("code", code);
		js.put("msg", msg);
		return js;
	}

	private JSONObject respJson(int code, String msg, JSONObject data) {
		JSONObject js = new JSONObject();
		js.put("code", code);
		js.put("msg", msg);
		js.put("data", data);
		return js;
	}

}
